-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CIR] New assembly format for function type return #1391
Conversation
Change the assembly format for `cir::FuncType` from ``` !cir.func<!returnType (!argType)> ``` to ``` !cir.func<(!argType) -> !returnType> ``` This change (1) is easier to parse because it doesn't require lookahead, (2) is consistent with the format of ClangIR `FuncOp` assembly, and (3) is consistent with function types in other MLIR dialects. Change all the tests to use or to expect the new format for function types. The contents and the semantics of `cir::FuncType` are unchanged. Only the assembly format is being changed. Functions that return `void` in C or C++ are still represented in MLIR as having no return type. Most of the changes are in `parseFuncType` and `printFuncType` and the functions they call in `CIRTypes.cpp`. A `FuncType::verify` function was added to check that an explicit return type is not `cir::VoidType`. `FuncType::isVoid()` was renamed to `FuncType::hasVoidReturn()` Some comments for `FuncType` were improved. An `llvm_unreachable` was added to `StructType::getKindAsStr` to suppress a compiler warning and to catch a memory error that corrupts the `RecordKind` field. (This was a drive-by fix and has nothing to do with the rest of this change.)
I considered renaming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending one nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
llvm::ArrayRef<mlir::Type> getReturnTypes() const; | ||
|
||
/// Returns whether the function returns void. | ||
bool isVoid() const; | ||
/// Does the fuction type return nothing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/fuction/function/ for the next PR.
Change the assembly format for
cir::FuncType
fromto
This change (1) is easier to parse because it doesn't require lookahead, (2) is consistent with the format of ClangIR
FuncOp
assembly, and (3) is consistent with function types in other MLIR dialects.Change all the tests to use or to expect the new format for function types.
The contents and the semantics of
cir::FuncType
are unchanged. Only the assembly format is being changed. Functions that returnvoid
in C or C++ are still represented in MLIR as having no return type.Most of the changes are in
parseFuncType
andprintFuncType
and the functions they call inCIRTypes.cpp
.A
FuncType::verify
function was added to check that an explicit return type is notcir::VoidType
.FuncType::isVoid()
was renamed toFuncType::hasVoidReturn()
Some comments for
FuncType
were improved.An
llvm_unreachable
was added toStructType::getKindAsStr
to suppress a compiler warning and to catch a memory error that corrupts theRecordKind
field. (This was a drive-by fix and has nothing to do with the rest of this change.)